package org.mechanic.exception;

import org.mechanic.core.web.HttpStatusCode;

/**
 * 微信异常
 */
public class WechatErrorException extends BaseException {

    private static final long serialVersionUID = -6357149550353160810L;

    private WechatError error;

    /**
     * 将微信的错误编码转换成系统错误编码
     *
     * @param error 微信错误编码
     */
    public WechatErrorException(WechatError error) {
        super(error.toString());
        this.error = error;
        httpStatusCode = HttpStatusCode.defineHttpStatusCode(error.getErrorCode(), error.getErrorMsg());
    }

    public WechatError getError() {
        return this.error;
    }

    @Override
    protected HttpStatusCode getHttpStatusCode() {
        return httpStatusCode;
    }
}
